//
//  DYCommentsReplyView.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/20.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYCommentsReplyView.h"

@interface DYCommentsReplyView ()

@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UITextView *replyTextView;
@property (nonatomic,strong)UIButton *submitButton;


@end


@implementation DYCommentsReplyView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {
        [self initView];
    }
    return self;
}
-(void)initView
{
    self.titleLabel = ({
        UILabel *label=[Utils labelWithTitle:@"回复评价：" titleFontSize:14 textColor:[UIColor xhq_aTitle] backgroundColor:WhiteColor alignment:0];
        label;
    });
    
    self.replyTextView = ({
       UITextView*  _textView=[[UITextView alloc]init];
        _textView.font=kFont(14);
        _textView.textColor=[UIColor xhq_content];
        _textView.backgroundColor=[UIColor xhq_section];
        [_textView xhq_cornerRadius:5];
        _textView.textContainerInset = UIEdgeInsetsMake(BILIWIDTH(10),BILIWIDTH(5),BILIWIDTH(10), BILIWIDTH(5));
        _textView;
    });
    
    self.submitButton = ({
        UIButton *button=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:WhiteColor action:@selector(submitButtonClick) target:self title:@"提交回复" image:nil font:14 textColor:[UIColor xhq_base]];
        [button xhq_cornerRadius:BILIHEIGHT(5)];
        [button xhq_borderColor:[UIColor xhq_base] borderWidth:BILIWIDTH(1)];
        button;
    });
    
    [self addSubview:self.titleLabel];
    [self addSubview:self.replyTextView];
    [self addSubview:self.submitButton];
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(10));
        make.top.equalTo(BILIHEIGHT(13));
    }];
    
    [self.replyTextView makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(10));
        make.right.equalTo(BILIWIDTH(-10));
        make.top.equalTo(self.titleLabel.bottom).offset(BILIHEIGHT(15));
        make.height.equalTo(BILIHEIGHT(185));
    }];
    
    [self.submitButton makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self.replyTextView.bottom).offset(BILIHEIGHT(30));
        make.size.equalTo(CGSizeMake(BILIWIDTH(88), BILIHEIGHT(32)));
    }];
    
}
-(void)submitButtonClick
{
    if (self.replyTextView.text.length>0) {
        !self.replyBlock?:self.replyBlock(self.replyTextView.text);
    }else{
        XHQHUDTEXT(@"回复内容不得为空");
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
